/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package movetransfiles.ftp;

import it.sauronsoftware.ftp4j.FTPClient;
import it.sauronsoftware.ftp4j.FTPException;
import it.sauronsoftware.ftp4j.FTPIllegalReplyException;
import java.io.IOException;

/**
 *
 * @author srkrishnan
 */
public class FTPUtil {
    public static FTPClient connect(String host,String username,String password)
    {
        FTPClient srcftp=null;
        try {
            srcftp = new FTPClient();

            srcftp.connect(host);
            srcftp.login(username,password);
            //srcftp.setPassive(false);
            System.out.println("Connected to FTP... " + srcftp.getHost());
        } catch (IllegalStateException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (FTPIllegalReplyException ex) {
            ex.printStackTrace();
        } catch (FTPException ex) {
           ex.printStackTrace();
        }
        return srcftp;
    }
}
